#引入依赖包
import cx_Oracle

# 数据库连接信息
username = "scott"
password = "123456"
dsn = "localhost:1521/orcl"  # 或者使用TNS名称: cx_Oracle.makedsn('host', 'port', 'sid')
cx_Oracle.init_oracle_client(lib_dir=r"c:\instantclient-basic-windows.x64-23.8.0.25.04\instantclient_23_8")
# 创建连接
connection = cx_Oracle.connect(user=username, password=password, dsn=dsn)

# 创建一个cursor对象
cursor = connection.cursor()

# 执行查询
cursor.execute("SELECT * FROM emp")

# 获取所有结果
for row in cursor:
    print(row)

# 关闭cursor和连接
cursor.close()
connection.close()